import java.io.*;
import java.net.*;

public class antServer{
	public static void main(String[] arg) throws Exception{
		ServerSocket ss = new ServerSocket(3003);
		int nr = 0;
		while(true){
			Socket sc = ss.accept();
			System.out.println(sc);
			PrintWriter vorku = new PrintWriter(sc.getOutputStream(), true);
			nr++;
			vorku.println("Martini programm ütleb "+nr+" tere");
			vorku.println("Kes ssa oled?");
			BufferedReader br = new BufferedReader(new InputStreamReader(sc.getInputStream()));
			String kirjeldus = br.readLine();
			vorku.println("Ahoi, "+ kirjeldus);
			sc.close();
		}
	}
}